﻿<%@ Page Language="C#" MasterPageFile="MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" Title="Beta Books | Home" %>
<%@ MasterType virtualPath="~/MasterPage.master"%>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <span class="heading">Home</span>
    <table class="contentTable">
        <tr>
            <td style="height:22px;width:20px;background-image:url('images/ictl.png');background-position: top;background-repeat:no-repeat"></td>
            <td style="background-image:url('images/bg.png');"></td>
            <td style="height:22px;width:20px;background-image:url('images/ictr.png');background-position: top;background-repeat:no-repeat"></td>
        </tr>
        <tr class="contentbg">
            <td></td>
            <td>
                <asp:Label ID="Label3" runat="server" Text="Search by Category"></asp:Label>
                <asp:DropDownList ID="categorySearchDropDownList" runat="server" 
                    AutoPostBack="True" DataSourceID="categoryDataSource" DataTextField="Category" 
                    DataValueField="Category"  CssClass="button">
                </asp:DropDownList>
                <asp:AccessDataSource ID="categoryDataSource" runat="server" 
                    DataFile="App_Data/db.mdb"
                    SelectCommand="SELECT * FROM [Categories] ORDER BY [Category]">
                </asp:AccessDataSource>
                <asp:AccessDataSource ID="bookDataSource" runat="server"  
                        SelectCommand="SELECT Books.*,Categories.Category FROM Categories INNER JOIN Books ON Categories.CategoryID=Books.CategoryID ORDER BY [Category], [Title] " 
                        DataFile="<%$ ConnectionStrings:Books %>" >
                    <FilterParameters>
                        <asp:ControlParameter ControlID="categorySearchDropDownList"
                            PropertyName="SelectedValue" />
                    </FilterParameters>
                </asp:AccessDataSource>           
                
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="6"
                        DataSourceID="bookDataSource" AutoGenerateColumns="False"
                         GridLines="Horizontal" BorderStyle="None" 
                        onprerender="GridView1_PreRender" Width="100%">
                        <Columns>
                            <asp:TemplateField>
                            <ItemTemplate>
                                <img alt="Front Cover" class="bookImage" src="bookImages/<%# Eval("Picture") %>" />
                            </ItemTemplate>         
                            </asp:TemplateField>
                            
                            <asp:TemplateField>
                            <ItemTemplate>
                                    <span class="title"><asp:LinkButton ID="titleLink"  runat="server" 
                                          OnCommand="titleLink_Command" CssClass="blueLink" CommandName="viewDetails" 
                                          CommandArgument=<%# Eval("ISBN") %> ><%# Eval("Title") %></asp:LinkButton></span><br />
                                    <span class="author">By <%# Eval("Author") %></span><br />
                                    <span class="edition">Edition: <%# Eval("Edition") %></span><br /><br />
                                    <span class="edition">Pub. Date: <%# Eval("PubDate") %></span><br />
                                    <span class="edition">Category: <%# Eval("Category") %></span><br />
                            </ItemTemplate>
                            </asp:TemplateField>
                            
                            <asp:TemplateField>
                            <ItemTemplate>
                                <span class="price">Price: <%# Eval("Price","{0:C}") %><br /></span>
                                <asp:Button ID="addButton" runat="server" Text="Add To Cart"  CssClass="button"
                                    CommandName="addToCart" CommandArgument=<%# Eval("ISBN") %> oncommand="addButton_Command" 
                                 />
                            </ItemTemplate>
                            </asp:TemplateField>
                       </Columns>
                        <AlternatingRowStyle BackColor="Silver" />
                    </asp:GridView> 
              </td>
              <td></td>
             </tr>
        <tr>
            <td style="height:22px;width:20px;background-image:url('images/icbl.png');background-position: top;background-repeat:no-repeat"></td>
            <td style="background-image:url('images/bg.png');"></td>
            <td style="height:22px;width:20px;background-image:url('images/icbr.png');background-position: top;background-repeat:no-repeat"></td>
        </tr>
    </table>
</asp:Content>

